home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / sviluppo / svilupp2 / strngs18.rdm < prev    next >
Text File  |  1997-01-18  |  15KB  |  532 lines

  1. Short:    Strings Library for programmers...
  2. Author:   Kåre Johansen (kaarej@barentsnett.no)
  3. Uploader: Kåre Johansen (kaarej@barentsnett.no)
  4. Version:  v1.8
  5. Type:     dev/misc
  6. Program:  strings.library (E example source included)
  7.  
  8.  
  9.                                  Prologue
  10.                                  --------
  11.  
  12.   Welcome to another release of strings.library.. This library was
  13.   meant for dos/shell purposes only when I first released v1.0.. 
  14.   This library can be used to everything.. I use this library in
  15.   doors coding, and other utilities that needs these kinds of
  16.   commands. I'm sure these commands will come in hand for you
  17.   aswell.. I have put alot of time within this library, and I
  18.   would apreachiate if anyone sent me bugs reports, features
  19.   what ever you want to see in strings.library.. My E-MAIL
  20.   can be found at the end of this documentation...
  21.  
  22.                               What is this!?
  23.                               --------------
  24.  
  25.   Well.. This library is based on a MODULE I made for AMIGA E for some
  26.   time back.. This lib is a tool based library, at this very moment
  27.   I have just made a few commands.. But, there will be more in the
  28.   future.. :) (Read the syntax for more info)...
  29.  
  30.  
  31.                            Arexx Kinda Commands
  32.                            --------------------
  33.  
  34.   StrWord()    - Converted cmd from Arexx called : Word      ()
  35.   Str2Number() - Converted cmd from Arexx called : C2D       ()
  36.   StrReplace() - Converted cmd from Arexx called : Translate ()
  37.   StrCopies()  - Converted cmd from Arexx called : Copies    ()
  38.   Fexists()    - Converted cmd from Arexx called : Exists    ()
  39.  
  40.                           What about the syntax!?
  41.                           -----------------------
  42.  
  43.   Here are a list of the supported commands..
  44.  
  45.   strings.library/StrCentre()               v1.0 bugFixed in v1.7
  46.   strings.library/StrWord()                 v1.0 bugFixed in v1.7
  47.   strings.library/StrRight()                v1.0 bugFixed in v1.7
  48.   strings.library/Str2Number()              v1.0 bugFixed in v1.7
  49.   strings.library/StrReplace()              v1.1 bugFixed in v1.7
  50.   strings.library/StrCopies()               v1.2 bugFixed in v1.7
  51.   strings.library/Version()                 v1.2
  52.   strings.library/Fexists()                 v1.3 Improved in v1.5
  53.   strings.library/PowNum()                  v1.4
  54.   strings.library/Asc2Num()                 v1.4
  55.   strings.library/Num2Bin()                 v1.5
  56.   strings.library/Str2Upper()               v1.6 bugFixed in v1.7
  57.   strings.library/Str2Lower()               v1.6 bugFixed in v1.7
  58.   strings.library/Num2Dec()                 v1.7
  59.   strings.library/VersionDate()             v1.7
  60.   strings.library/GetTime()                 v1.8 TIME/DATE command
  61.   strings.library/GetTicks()                v1.8 TIME/DATE command
  62.   strings.library/Tick2Time()               v1.8 TIME/DATE command
  63.   strings.library/SetTimer()                v1.8 TIME/DATE command
  64.   strings.library/GetTimer()                v1.8 TIME/DATE command
  65.  
  66. StrCentre() strings.library/StrCentre()
  67.  
  68.     NAME
  69.     StrCentre() -- Will center a text in SHELL/CLI
  70.  
  71.     SYNOPSIS
  72.     res:=StrCentre(text,length)
  73.  
  74.     FUNCTION
  75.     - This command will center a text in your SHELL/CLI window..
  76.  
  77.     INPUT/OUTPUTS
  78.     res    - Result
  79.     text   - The text you want to center on the screen
  80.     length - The length of your screen.. (Default 79) THIS -> WAY :)
  81.  
  82. StrWord() strings.library/StrWord()
  83.  
  84.     NAME
  85.     StrWord() -- Will locate a word in a text specified by you
  86.  
  87.     SYNOPSIS
  88.     res:=StrWord(text,word)
  89.  
  90.     FUNCTION
  91.     - This command will get the word you want to collect from a text
  92.       e.g : StrWord('Hello, this is a test',3) would be:
  93.                 IS
  94.  
  95.     INPUT/OUTPUTS
  96.     res  - Result
  97.     text - The text you want to get a word from
  98.     word - The word number you want to get
  99.  
  100.     BUGS
  101.     Somehow there has been a bug all the time when using this command.
  102.     The result sometimes produced more than ONE word, fixed in v1.5
  103.  
  104. StrRight() strings.library/StrRight()
  105.  
  106.     NAME
  107.     StrRight() -- Will write the text to the right in your SHELL window.
  108.  
  109.     SYNOPSIS
  110.     res:=StrRight(text,pos)
  111.  
  112.     FUNCTION
  113.     This command will print a text to the right of your SHELL/CLI
  114.     window..
  115.  
  116.     INPUT/OUTPUTS
  117.     res  - Result
  118.     text - The text you want to print to the right
  119.     pos  - The position on your screen (Default: 79)
  120.  
  121. Str2Number() strings.library/Str2Number()
  122.  
  123.     NAME
  124.     Str2Number() -- This command will convert a string to a number
  125.  
  126.     SYNOPSIS
  127.     res:=Str2Number(text)
  128.  
  129.     FUNCTION
  130.     This command will convert a text of 4 characters maximum to a
  131.     number.. E.g.:
  132.  
  133.     STRING        NUMERIC:
  134.     DOS        4476755
  135.     TEST        1413829460
  136.     JOHN        1246709838
  137.  
  138.     INPUT/OUTPUTS
  139.     res  - Result
  140.     text - The text you want to convert to a number...
  141.  
  142. StrReplace() strings.library/StrReplace()
  143.  
  144.     NAME
  145.     StrReplace() -- Will replace one character with another one
  146.  
  147.     SYNOPSIS
  148.     str:=StrReplace(text,repchar,repwith)
  149.  
  150.     FUNCTION
  151.     - This command will replace/or translate a text into the
  152.       character you want to replace in a text
  153.     e.g:
  154.  
  155.     str:=StrReplace('testing_a_little_bit','_',' ')
  156.  
  157.     Will output:
  158.  
  159.     testing a little bit
  160.  
  161.     INPUT/OUTPUTS
  162.     str     - Result
  163.     text    - The text you want to replace from
  164.     repchar - The letter you want to remove
  165.     repwith - The letter you want to insert instead of repchar
  166.  
  167.  
  168. StrCopies() strings.library/StrCopies()
  169.  
  170.     NAME
  171.     StrCopies() -- Will copy a char number of times to a string..
  172.  
  173.     SYNOPSIS
  174.     str:=StrCopies(copychar,times)
  175.  
  176.     FUNCTION
  177.     - This command will copy a char to a string x number of times..
  178.     e.g:
  179.  
  180.     str:=StrCopies('DOC',6)
  181.  
  182.     Will output:
  183.  
  184.     DOCDOCDOCDOCDOCDOC
  185.  
  186.     INPUT/OUTPUTS
  187.     str     - Result
  188.     copychar- The char you want to copy to the string
  189.     times   - How many times this you want the char to be copied
  190.  
  191. Version() strings.library/Version()
  192.  
  193.     Version() -- This will result version and revision version of SLIB
  194.                      This command should have been created long time ago,
  195.                      sorry about this...
  196.  
  197.     SYNOPSIS
  198.     version,revision=Version()
  199.  
  200.     FUNCTION
  201.  
  202.     OUTPUT
  203.     version  - The version number of strings.library
  204.     revision - The revision number of strings.library
  205.  
  206. Fexists() strings.library/Fexists()
  207.  
  208.     Fexists() -- This command will result FALSE or TRUE if a file
  209.                      exists or not..
  210.  
  211.     SYNOPSIS
  212.     result=Fexists()
  213.  
  214.     FUNCTION
  215.     This command will result back TRUE OR FALSE (-1/0), depending
  216.     if the file exists or not.
  217.  
  218.     result:=Fexists(filename)
  219.  
  220.     INPUT/OUTPUT
  221.     filename - Will be the name of the file you are checking for
  222.     result   - Result will be -1 or 0
  223.  
  224. PowNum() strings.library/PowNum()
  225.  
  226.     PowNum() -- This command will elevate 2 numbers..
  227.  
  228.     SYNOPSIS
  229.     result=PowNum(num1,num2)
  230.  
  231.     FUNCTION
  232.     This command will elevate num1 and num2.. Lets say I want to know
  233.     the square of num1 and num2 (e.g : 4^5 = 1024) then you can do
  234.     like this:
  235.  
  236.     result:=PowNum(4,5)
  237.  
  238.     In math it will look like this: 4*4*4*4*4 = 1024 
  239.  
  240.     INPUT/OUTPUT
  241.     Result   - Result
  242.     num1     - Will be the number you want to elevate with
  243.         num2     - The number of times you want to multiply num1
  244.         result   - Will be the sum of the calculation
  245.  
  246. Asc2Num() strings.library/Asc2Num()
  247.  
  248.     Asc2Num() -- This command will produce the ascii value of a char
  249.  
  250.     SYNOPSIS
  251.     result=Asc2Num(char)
  252.  
  253.     FUNCTION
  254.     This command will produce the ascii value of a char, lets say I
  255.         want to know what ascii value the letter/char A are.. ONLY one (1)
  256.     character is allowed... 
  257.  
  258.     result:=Asc2Num('A')
  259.  
  260.     The result will be: 65
  261.  
  262.     INPUT/OUTPUT
  263.     result   - Result
  264.     char     - This will be the character you want to convert to a number
  265.  
  266. Num2Bin() strings.library/Num2Bin()
  267.  
  268.     Num2Bin() -- This will convert a number value into a binary number
  269.  
  270.     SYNOPSIS
  271.     result=Num2Bin(number)
  272.  
  273.     FUNCTION
  274.     This command will convert a DEC number to binary
  275.  
  276.     result:=Num2Bin(173)
  277.  
  278.     The result will be: 10101101
  279.  
  280.     INPUT/OUTPUT
  281.     result   - Result
  282.     Number   - The number you want to convert to binary
  283.  
  284.  
  285. Str2Upper() strings.library/Str2Upper()
  286.  
  287.     Str2Upper() -- This will convert a string to uppercase
  288.  
  289.     SYNOPSIS
  290.     result=Str2Upper(text)
  291.  
  292.     FUNCTION
  293.     This command will convert a text to uppercased, this command will
  294.         also handle the norwegian letters: Æ, Ø and Å...
  295.  
  296.     result:=Str2Upper('aBCøæÅ')
  297.  
  298.     The result will be: ABCØÆÅ
  299.  
  300.     INPUT/OUTPUT
  301.     result   - Result
  302.     text     - The text you want to convert to uppercase..
  303.  
  304.  
  305. Str2Lower() strings.library/Str2Lower()
  306.  
  307.     Str2Lower() -- This will convert a string to lowercase
  308.  
  309.     SYNOPSIS
  310.     result=Str2Lower(text)
  311.  
  312.     FUNCTION
  313.     This command will convert a text to lowercase, this command will
  314.         also handle the norwegian letters: Æ, Ø and Å...
  315.  
  316.     result:=Str2Lower('aBCøæÅ')
  317.  
  318.     The result will be: abcøæå
  319.  
  320.     INPUT/OUTPUT
  321.     result   - Result
  322.     text     - The text you want to convert to lowercase..
  323.  
  324. Num2Dec() strings.library/Num2Dec()
  325.  
  326.     Num2Dec() -- This will convert a string number to a fixed number
  327.  
  328.     SYNOPSIS
  329.     result=Num2Dec(number,fix)
  330.  
  331.     FUNCTION
  332.     This command will convert a number to a fixed number, e.g:
  333.  
  334.     result:=Num2Dec(1000000,3)
  335.     result:=Num2Dec(100000,3)
  336.     result:=Num2Dec(100000,2)
  337.  
  338.     The result will be: 1.000.000
  339.     The result will be: 100.000
  340.     The result will be: 10.00.00
  341.  
  342.     INPUT/OUTPUT
  343.     result  - Result
  344.         number  - The number you want to be fixed
  345.                   in Amiga E : StringF(number,'\s
  346.     fix     - How many digits before a comma (.) (from the right)
  347.  
  348. VersionDate() strings.library/VersionDate()
  349.  
  350.     Version() -- This will result the date of creation of library
  351.  
  352.     SYNOPSIS
  353.     date=VersionDate()
  354.  
  355.     FUNCTION
  356.  
  357.     OUTPUT
  358.     Date     - Date (time) of creation of strings.library (when compiled)
  359.  
  360.  
  361. GetTime() strings.library/GetTime()
  362.  
  363.     GetTime() -- This will result the day, date, time as an argument
  364.  
  365.     SYNOPSIS
  366.     result=GetTime()
  367.  
  368.     FUNCTION
  369.         This function will get the current day, date and time as an argument.
  370.         To separate them, use StrWord() to get them! :)
  371.  
  372.     OUTPUT
  373.     result    - day, date and time (eg: Monday 01-Jan-1997 00:01:30)
  374.  
  375.  
  376. GetTicks() strings.library/GetTicks()
  377.  
  378.     GetTicks() -- This will result the day, date, time as an argument
  379.  
  380.     SYNOPSIS
  381.     result=GetTicks()
  382.  
  383.     FUNCTION
  384.         This function will get the current day, date and time as an argument,
  385.         but as dayticks, dateticks and ticks.. To separate them,
  386.         use StrWord() to get them! :)
  387.  
  388.     OUTPUT
  389.     result    - day, date and time (eg: 6925 698 859)
  390.  
  391. Tick2Time() strings.library/GetTicks()
  392.  
  393.     Tick2Time() -- This will result the day, date, time as an argument
  394.  
  395.     SYNOPSIS
  396.     result=GetTicks(dayticks, dateticks, timeticks)
  397.  
  398.     FUNCTION
  399.         This function will get the current day, date and time as an argument,
  400.     using dayticks, dateticks and timeticks values, useful for BBS
  401.         coders when converting "timestamp" to a date.. To separate them
  402.         use StrWord() to get them! :)
  403.  
  404.     INPUT
  405.         dayticks  - Timestamp Dayticks (see output)
  406.     dateticks - Timestamp Dateticks (see output)
  407.         timeticks - Timestamp Timeticks (see output)
  408.  
  409.     OUTPUT
  410.     result    - day, date and time as a string argument..
  411.  
  412.                          Ticks             Converted Ticks
  413.                     ---------------------------------------------
  414.                      6925 698 859     Tuesday 17-Dec-96 11:38:17
  415.  
  416. SetTimer() strings.library/SetTimer()
  417.  
  418.     SetTimer() -- This command will reset or set a timer for you
  419.  
  420.     SYNOPSIS
  421.     SetTimer(mins,secs)
  422.  
  423.     FUNCTION
  424.     This command will calculate a timer/counter that will count from
  425.         the values you enter in the parameters..
  426.  
  427.         e.g: SetTimer(59,30) will set the timer to: 00:59:30
  428.  
  429.     INPUT
  430.     mins   - How many minutes/hours the timer should be set to..
  431.         secs   - How many seconds/minutes the timer should be set to..
  432.  
  433. GetTimer() strings.library/GetTimer()
  434.  
  435.     GetTimer() -- This command will get the timer you set with
  436.                       SetTimer.. If you don't set anything with the
  437.                       SetTimer(), the GetTimer() will use the real
  438.                       timer (your clock :))... 
  439.  
  440.     SYNOPSIS
  441.     result:=GetTimer()
  442.  
  443.     FUNCTION
  444.     
  445.     This function will calculate the new timer as the new result.
  446.  
  447.     OUTPUT
  448.     result  - The new timer result (e.g: 00:00:00)
  449.  
  450.  
  451.  
  452.                              Bugs/news/Hisory
  453.                              ----------------
  454.   v1.8
  455.   - Added new command SetTimer()
  456.   - Added new command GetTimer()
  457.   The following 3 date/time commands results a 3 args string, to get them
  458.   use StrWord() or FindArg() from DOS.LIBRARY...
  459.  
  460.   - Added new command GetTime()
  461.   - Added new command GetTicks()
  462.   - Added new command Tick2Time()
  463.  
  464.   v1.7
  465.   - Rewrote StrWord() again !... (Gosj, I'm getting tired of this)..
  466.   - Added new command Num2Dec()
  467.   - Fixed a major bug in all Str commands!!... If used more than one (1)
  468.     time after each other, the value would be the same as the last one, eg
  469.  
  470.     word:='Hello again'
  471.     Printf('\s (word 1) \s (word 2)\n',StrWord(word,1),StrWord(word,2))
  472.  
  473.     Results : Word 1 = "again"   Word 2 = "again"
  474.  
  475.     All commands has been prefixed..
  476.  
  477.   v1.6
  478.   - Added new command Str2Upper()
  479.   - Added new command Str2Lower()
  480.  
  481.   - Internal release
  482.  
  483.   v1.5
  484.   - StrWord() did something weird with the "in variable" if there was
  485.     more than 1 StrWord(); Eg
  486.  
  487.     --------------
  488.     buff:='Hello my friend'
  489.  
  490.     var1:=StrWord(buff,1)
  491.     var2:=StrWord(buff,2)
  492.     var3:=StrWord(buff,3)
  493.  
  494.     The var1, var2 and var3 contained ALL the same value -> FRIEND..
  495.     --------------
  496.     - Rewrote some of the StrWord() routine once again
  497.  
  498.   v1.4
  499.   - Found a bug in the StrWord() command, this command added more
  500.     than one word to the result string, fixed..
  501.   - Optimized the Fexists() command. When using this, Fexists will
  502.     no longer open a requester when a path doesn't exist. Rewrote
  503.     the return result codes:
  504.     0 = File not found
  505.     1 = File exists
  506.     2 = Device not mounted
  507.   - Optimized/fixed the StrReplace() command, now you can replace
  508.     more than ONE char in a text... Replace/insert words/sentences
  509.     or a single char...
  510.  
  511.  
  512. -------------------------------------------------------------------------------
  513.                             Programmers Notice!
  514.                             -------------------
  515.  
  516.   Libraries created by E should be opened/closed by any one task EXACTLY
  517.   ONCE, not more, not less (this shouldn't pose any problems though).
  518.   Strange things WILL happen if you don't obey this rule.
  519.  
  520. ------------------------------------------------------------------------------
  521.                              For contacting me
  522.                              -----------------
  523.  
  524.                        E-MAIL: kaarej@barentsnett.no
  525.  
  526.                                     OR
  527.  
  528.                      BBS: Key Stroke BBS +47-7847-1042
  529. ------------------------------------------------------------------------------
  530.  
  531.                That should be all... Happy programming.. :)
  532.